Skip to content

refactor: derive database URIs from a single MONGODB_URI base#113

Open
m4nojTudu wants to merge 1 commit intoTiledesk:masterfrom
m4nojTudu:refactor/derive-db-uris
Open

refactor: derive database URIs from a single MONGODB_URI base#113
m4nojTudu wants to merge 1 commit intoTiledesk:masterfrom
m4nojTudu:refactor/derive-db-uris

Conversation

@m4nojTudu
Copy link
Copy Markdown

@m4nojTudu m4nojTudu commented Feb 19, 2026

What

Replaces hardcoded MongoDB connection strings in config/database.js
with a buildDbUri helper that derives databaselogs and databasetest
URIs from the primary connection string.

Why

When deploying against a remote cluster (e.g. mongodb+srv://), the logs
and test databases still pointed at localhost unless their dedicated env
vars were set. This makes them automatically follow the primary URI.

Backward compatibility

  • No env vars set → same localhost:27017 defaults as before
  • MONGODB_URI_LOGS / MONGODB_URI_TEST remain optional overrides
  • No changes to any consumers of config.database, config.databaselogs,
    or config.databasetest

How to test

npx mocha test/config/buildDbUri.test.js


Note

Low Risk
Configuration-only change with small, well-tested string parsing; main risk is misconstructed URIs for uncommon MongoDB connection string formats.

Overview
Refactors config/database.js to build databaselogs and databasetest URIs from the primary MONGODB_URI (falling back to the existing localhost default), instead of hardcoding separate localhost connection strings.

Adds a buildDbUri() helper that swaps/creates the database path while preserving query params, makes secret configurable via JWT_SECRET, and introduces Mocha tests covering common MongoDB URI formats and edge cases.

Written by Cursor Bugbot for commit 444c9fa. This will update automatically on new commits. Configure here.

- Replace hardcoded localhost URIs with buildDbUri helper
- Logs and test databases now follow the primary connection string
- Add env var support for JWT_SECRET
- MONGODB_URI_LOGS and MONGODB_URI_TEST remain optional overrides
- Backward compatible: defaults unchanged when no env vars are set
- Add unit tests for buildDbUri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant